<template>
  <div class="WorkingSchedule" v-loading="loading">
    <el-form ref="form" :model="form" label-position="top" class="myform">
      <div>
        <el-form-item label="供应商" class="myform-item">
          <el-input
            v-model="form.title"
            placeholder="请输入款式编码(货号)/SKU编码/商品名称"
            clearable
            @keyup.enter.native="onSearch"
          ></el-input>
        </el-form-item>
        <el-form-item label="预约日期" class="myform-item">
          <el-date-picker
            v-model="form.start_time"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            value-format="yyyy-MM-dd"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="预约类型" class="myform-item">
          <el-select
            v-model="form.type"
            placeholder="请选择"
            clearable
            @keyup.enter.native="onSearch"
          >
            <el-option
              v-for="item in makeTypeList"
              :key="item.value"
              :label="item.title"
              :value="item.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="预约状态" class="myform-item">
          <el-select
            v-model="form.status"
            placeholder="请选择"
            clearable
            @keyup.enter.native="onSearch"
          >
            <el-option
              v-for="item in makeStateList"
              :key="item.value"
              :label="item.title"
              :value="item.value"
            ></el-option>
          </el-select>
        </el-form-item>
        
        <el-form-item style="margin-top: 50px">
          <el-button type="primary" @click="onSearch">查询</el-button>
        </el-form-item>
      </div>
      <div>
        <el-form-item style="margin-top: 50px">
          <el-button type="primary" @click="onEdit()" icon="el-icon-plus"
            >新建</el-button
          >
        </el-form-item>
      </div>
    </el-form>
    <el-table :data="tableData" style="width: 100%" border>
      <el-table-column
        label="供应商"
        align="company"
        prop="type_no"
      ></el-table-column>
      <el-table-column label="预约时间" align="center" prop="date">
      </el-table-column>
      <el-table-column label="预约类型" align="center" prop="type">
      </el-table-column>
      <el-table-column label="数量" align="center" prop="num">
      </el-table-column>
      <el-table-column label="人员信息" align="center" prop="personnel">
        <template slot-scope="{ row }">
          <el-table :data="row.personnel" style="width: 100%" border>
            <el-table-column label="姓名" align="center" prop="name">
            </el-table-column>
            <el-table-column label="手机号" align="center" prop="tel">
            </el-table-column>
            <el-table-column label="车牌号" align="center" prop="type">
            </el-table-column>
          </el-table>
        </template>
      </el-table-column>
      <el-table-column
        label="申请日期"
        align="center"
        prop="remarks"
      ></el-table-column>
      <el-table-column
        label="预约状态"
        align="center"
        prop="remarks"
      ></el-table-column>
      <el-table-column
        label="接收状态"
        align="center"
        prop="remarks"
      ></el-table-column>
      <el-table-column
        label="接收时间"
        align="center"
        prop="remarks"
      ></el-table-column>
      <el-table-column
        label="备注"
        align="center"
        prop="remarks"
      ></el-table-column>
    </el-table>
    <pagination
      :form="form"
      :total="total"
      @paginationPostOrderTaskList="postApiAdminOrderIndex"
    />
    <!-- <el-dialog title="新建分类" :visible.sync="dialogVisible" width="30%">
            <el-form :model="tagform" :rules="rules" ref="tagform" label-width="100px">
                <el-form-item label="分类名称" prop="title">
                    <el-input
                        v-model="tagform.title"
                        placeholder="请输入分类名称"
                        clearable
                        style="width:70%"
                    ></el-input>
                </el-form-item>
                <el-form-item label="标签底色" prop="font_color">
                    <el-color-picker v-model="tagform.font_color"></el-color-picker>
                </el-form-item>
                <el-form-item label="排序" prop="listorder">
                    <el-input
                        v-model="tagform.listorder"
                        placeholder="请输入排序"
                        clearable
                        style="width:70%"
                    ></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button @click="dialogVisible = false">取 消</el-button>
                    <el-button type="primary" @click="onClickSubmit('tagform')">确 定</el-button>
                </el-form-item>
            </el-form>
        </el-dialog> -->
  </div>
</template>

<script>
import {
  postApiAdminOrderIndex,
  postHomeCodeGetFactory,
  postAdminOperateDelOrtherProduct,
  postAdminOperateDisablEOrtherProduct,
} from "@/api";
import pagination from "@/components/pagination.vue";
export default {
  components: { pagination },
  data() {
    return {
      loading: false,
      dialogVisible: false, //审核
      makeTypeList: [
        {
            title:"预约",
            value:1
        },
        {
            title:"取货",
            value:2
        },
        {
            title:"维修",
            value:3
        }
      ],
      makeStateList: [
        {
            title:"待审核",
            value:1
        },
        {
            title:"已通过",
            value:2
        },
        {
            title:"已拒绝",
            value:3
        },
        {
            title:"已接收",
            value:4
        },
        {
            title:"拒接收",
            value:5
        },
        {
            title:"已撤销",
            value:6
        },
        {
            title:"已过期",
            value:9
        }
      ],
      form: {
        start_time: "",
        end_time:"",
        type: "",
        status:"",
        page: 1,
        size: 10,
      },
      tableData: [],
      total: 1,
    };
  },
  activated() {
    let form = this.form;
    this.postApiAdminOrderIndex(form);
  },
  methods: {
    // 查看
    onEdit(id) {
      if (!id) {
        this.$router.push({
          name: "OperationalDepartmentNotForSaleEdit",
        });
      } else {
        this.$router.push({
          name: "OperationalDepartmentNotForSaleEdit",
          query: { id },
        });
      }
    },
    async onIs(id, status) {
      let obj = {
        id: id,
        is_disable: status,
      };
      this.$confirm(`确定${status == 0 ? "禁用" : "启用"}`, "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(async () => {
          await postAdminOperateDisablEOrtherProduct(obj);
          let form = this.form;
          this.postApiAdminOrderIndex(form);
        })
        .catch(() => {});
    },
    // 删除
    onDelete(id) {
      let obj = {
        id,
      };
      let { form } = this;
      this.$confirm("确定删除该标签种类?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          postAdminOperateDelOrtherProduct(obj).then((res) => {
            this.postApiAdminOrderIndex(form);
            this.$message({
              type: "success",
              message: "删除成功!",
            });
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },

    // 采购列表
    async postApiAdminOrderIndex(data) {
      this.loading = true;
      this.form = data;
      postApiAdminOrderIndex(data)
        .then((res) => {
          this.loading = false;
          console.log("采购列表", res);
          this.tableData = res.data;
          this.total = Number(res.total);
        })
        .catch((err) => {
          this.loading = false;
        });
    },
    // 搜索
    onSearch() {
      this.form.page = 1;
      this.form.size = 10;
      this.postApiAdminOrderIndex(this.form);
    },
  },
};
</script>

<style lang="scss" scoped>
.myform {
  display: flex;
  justify-content: space-between;
  > div {
    display: flex;
  }
  &-item {
    margin-right: 10px;
  }
}
.WorkingSchedule {
  background: #ffff;
  padding: 20px;
  border-radius: 2px;
  @include boxShadow;
}
</style>
